/* eslint-disable no-tabs */
const minioUrl: string = import.meta.env.VITE_APP_MINIO_URL as string

export function handleMinioUrl(url: string | undefined): string {
    // console.log(minioUrl);
    let tempMinioUrl: string = minioUrl
    const matched = minioUrl?.match?.(/^(.+)\/$/)
    if (matched) {
        tempMinioUrl = matched[1]
    }
    if (url) {
        if (url.indexOf("http") > -1) {
            return url
        } else if (url[0] === "/") {
            return tempMinioUrl + url
        } else {
            return tempMinioUrl + "/" + url
        }
    } else {
        return ""
    }
}
